package com.cs.pk.codestriker;

import java.io.IOException;

import org.eclipse.swt.widgets.Combo;

import com.cs.pk.utils.ClearCaseException;
import com.cs.pk.utils.UtilRepository;

public class Activity extends AbstractPopulateList{

	private Combo activity = null;
	
	public Activity(Object component) {
		super(component);
		activity = (Combo)component;
	}

	public void populate(Object payload) throws IOException, InterruptedException, ClearCaseException {
		String viewTag = (String)payload;
		String activities = runBatFile(new String[] {/*Activator.getDefault().clearcase_file_path,"activity"*/"cleartool lsactivity -s -vie "+ viewTag});
		String tokens[] = activities.split("\n");
		for (int i = 1; i < tokens.length; i++) {
			UtilRepository.updateViewActivityRepository(tokens[i].trim(), viewTag);
			activity.add(tokens[i].trim());
		}
	}

	public String filterOutput() {
		return result.trim();
	}

	protected int getRepositoryType() {
		return UtilRepository.ACTIVITY_REPOSITORY;
	}
	
	public void clear() {
		activity.removeAll();
	}

}
